<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>王者荣耀竞猜管理平台</title>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/jquery-easyui-1.5.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/jquery-easyui-1.5.3/themes/icon.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/kindeditor/themes/default/default.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/kindeditor/plugins/code/prettify.css"/>

    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/jquery-easyui-1.5.3/jquery.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
    <script charset="utf-8" src="${pageContext.request.contextPath}/static/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="${pageContext.request.contextPath}/static/kindeditor/lang/zh-CN.js"></script>
    <script charset="utf-8"
            src="${pageContext.request.contextPath}/static/kindeditor/plugins/code/prettify.js"></script>

</head>
<body>
<div align="center">
    <form id="ff" method="post" action="/webSiteSetting/save" enctype="multipart/form-data">
        <table cellpadding="5">
            <tr>
                <td>公告标题：</td>
                <td><input class="easyui-textbox" type="text" id="fdTitle" name="fdTitle" data-options="required:true"/>
                </td>
            </tr>
            <tr>
                <td>公告内容：</td>
                <td><input id="fdContent" type="hidden" name="fdContent">
                    <textarea  name="content" cols="100" rows="12"
                              style="width:650px;height:270px;"></textarea>
                </td>
            </tr>
            <tr>
                <td>标题颜色：</td>
                <td><input type="color" id="fdColor" name="fdColor"/>
                </td>
            </tr>
            <tr>
                <td>公告类型：</td>
                <td>
                    <input type="radio" name="fdType" value="0" checked/>系统公告
                    <input type="radio" name="fdType" value="1"/>活动公告
                    <input type="radio" name="fdType" value="2"/>新闻资讯
                </td>
            </tr>
            <tr>
                <td>顶部背景图：</td>
                <td>
                    <input class="easyui-filebox" name="bg" id="bg"
                           data-options="prompt:'选择图片...',buttonText:'选择背景',accept: 'image/*',buttonAlign:'right',editable:false">
                </td>
            </tr>

            <tr>
                <td>是否启用：</td>
                <td>
                    <input type="radio" name="fdIsEnable" value="1" checked/>是
                    <input type="radio" name="fdIsEnable" value="0"/>否
                </td>
            </tr>
            <tr>
                <td>排序：</td>
                <td><input class="easyui-textbox" type="text" id="fdOrder" name="fdOrder" data-options="required:true"/>
                </td>
            </tr>
        </table>
    </form>
    <div style="text-align:center;padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
        <a href="javascript:void(0)" style="margin-left: 20px" class="easyui-linkbutton" onclick="clearForm()">重置</a>
    </div>
</div>
</body>
<script>
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name="content"]', {
            cssPath : '/static/kindeditor/plugins/code/prettify.css',
            uploadJson : '/static/kindeditor/jsp/upload_json.jsp',
            fileManagerJson : '/static/kindeditor/jsp/file_manager_json.jsp',
            allowFileManager : true,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                });
            }
        });
        prettyPrint();
    });
    function submitForm() {
       var html = editor.html();
       $("#fdContent").val(html);
        $('#ff').form('submit', {
            onSubmit: function () {
                return $(this).form('enableValidation').form('validate');
            },
            success: function (data) {
                var r = JSON.parse(data);
                if (r.code == 0) {
                    $.messager.alert("提示", r.msg, "info");
                    parent.closeWin();
                    parent.reLoad();
                    parent.clearSelections();
                } else {
                    $.messager.alert("提示", r.msg, "Warning")
                }
            }
        });
    }
    function clearForm() {
        $('#ff').form('clear');
    }
</script>
</html>